package com.xcc.core.spring.controller.taobao;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.taobao.api.DefaultTaobaoClient;
import com.taobao.api.TaobaoClient;
import com.taobao.api.request.TbkTpwdCreateRequest;
import com.taobao.api.response.TbkTpwdCreateResponse;
import com.xcc.core.util.taobao.TaobaoUtil;

@RestController
public class TranTaobaoController {

    @Autowired
    TaobaoUtil mTaobaoUtil;
    //   https://s.click.taobao.com/wyvBKsu
    @RequestMapping(value="taobaourl",method =RequestMethod.GET)
    public Object getURl(String url,String txt) throws Exception {
        TbkTpwdCreateRequest req = new TbkTpwdCreateRequest(); 
        req.setText((txt==null||txt.length()<5)?"长度大于5个":txt);
        System.out.println(url);
        req.setUrl(url);
        TbkTpwdCreateResponse response = mTaobaoUtil.getClient().execute(req);
        System.out.println(response.getBody());
        return response.getBody();
    }

}
